package cn.gson.springboot.model.pjos;

import cn.afterturn.easypoi.excel.annotation.Excel;

import javax.persistence.*;
import java.sql.Date;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

@Entity
public class Emp {
    private int employeesId;//员工id
    private String empName;//员工名称
    private String empSex;//性别
    private String empPhone;//电话
    private String empAddressProvince;//地址省
    private String empAddressCity;//地址市
    private String empAddressArea;//地址区/县
    private String empAddressDetailed;//详细地址
    private String empCard;//身份证号
    private String empIsNot;//在职/离职
    private String accountName;//用户名
    private String empPwd;//密码
    private Timestamp empDate;//创建时间
    private Date dateEntry;//入职时间
    private  int empDelete;//删除状态
    private Collection<Culog> culogsByEmployeesId;
    private Dept deptByDeptsId;
    private  String empImgpath;
    private List<Position> positionList;//角色
    private Collection<Evection> evectionsByEmployeesId;
    private Collection<Expense> expensesByEmployeesId;
    private Collection<Target> targetsByEmployeesId;
    private Collection<Reply> replyByEmployeesId;
    private Collection<CheckDetails> checkDetailsByEmployeesId;

    @ManyToMany
    @JoinTable(name = "emp_position",
            joinColumns = {
                    @JoinColumn(name="employees_id")
            },
            inverseJoinColumns = {
                    @JoinColumn(name = "post_id")
            })
    public List<Position> getPositionList() {
        return positionList;
    }

    public void setPositionList(List<Position> positionList) {
        this.positionList = positionList;
    }

    @Basic
    @Column(name = "Emp_name")
    public String getEmpName() {
        return empName;
    }

    public void setEmpName(String empName) {
        this.empName = empName;
    }

    @Basic
    @Column(name = "Emp_sex")
    public String getEmpSex() {
        return empSex;
    }

    public void setEmpSex(String empSex) {
        this.empSex = empSex;
    }

    @Basic
    @Column(name = "Emp_phone")
    public String getEmpPhone() {
        return empPhone;
    }

    public void setEmpPhone(String empPhone) {
        this.empPhone = empPhone;
    }

    @Basic
    @Column(name = "Emp_address_province")
    public String getEmpAddressProvince() {
        return empAddressProvince;
    }

    public void setEmpAddressProvince(String empAddressProvince) {
        this.empAddressProvince = empAddressProvince;
    }

    @Basic
    @Column(name = "Emp_address_area")
    public String getEmpAddressArea() {
        return empAddressArea;
    }

    public void setEmpAddressArea(String empAddressArea) {
        this.empAddressArea = empAddressArea;
    }

    @Basic
    @Column(name = "Emp_address_city")
    public String getEmpAddressCity() {
        return empAddressCity;
    }

    public void setEmpAddressCity(String empAddressCity) {
        this.empAddressCity = empAddressCity;
    }
    @Basic
    @Column(name = "Emp_address_detailed")
    public String getEmpAddressDetailed() {
        return empAddressDetailed;
    }

    public void setEmpAddressDetailed(String empAddressDetailed) {
        this.empAddressDetailed = empAddressDetailed;
    }

    @Basic
    @Column(name = "Emp_card")
    public String getEmpCard() {
        return empCard;
    }

    public void setEmpCard(String empCard) {
        this.empCard = empCard;
    }


    @Basic
    @Column(name = "Emp_is_not")

    public String getEmpIsNot() {
        return empIsNot;
    }

    public void setEmpIsNot(String empIsNot) {
        this.empIsNot = empIsNot;
    }

    @Basic
    @Column(name = "Account_name")
    public String getAccountName() {
        return accountName;
    }

    public void setAccountName(String accountName) {
        this.accountName = accountName;
    }

    @Basic
    @Column(name = "Emp_pwd")
    public String getEmpPwd() {
        return empPwd;
    }

    public void setEmpPwd(String empPwd) {
        this.empPwd = empPwd;
    }

    @Basic
    @Column(name = "Emp_date")
    public Timestamp getEmpDate() {
        return empDate;
    }

    public void setEmpDate(Timestamp empDate) {
        this.empDate = empDate;
    }

    @Basic
    @Column(name = "Date_entry")
    public Date getDateEntry() {
        return dateEntry;
    }

    public void setDateEntry(Date dateEntry) {
        this.dateEntry = dateEntry;
    }

    @Id
    @Column(name = "employees_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY,generator = "seq")
    public int getEmployeesId() {
        return employeesId;
    }

    public void setEmployeesId(int employeesId) {
        this.employeesId = employeesId;
    }

    @Basic
    @Column(name = "Emp_imgpath")
    public String getEmpImgpath() {
        return empImgpath;
    }

    public void setEmpImgpath(String empImgpath) {
        this.empImgpath = empImgpath;
    }


    @Basic
    @Column(name = "Emp_delete")
    public int getEmpDelete() {
        return empDelete;
    }

    public void setEmpDelete(int empDelete) {
        this.empDelete = empDelete;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Emp emp = (Emp) o;
        return employeesId == emp.employeesId &&
                Objects.equals(empName, emp.empName) &&
                Objects.equals(empSex, emp.empSex) &&
                Objects.equals(empPhone, emp.empPhone) &&

                Objects.equals(empCard, emp.empCard) &&
                Objects.equals(empIsNot, emp.empIsNot) &&
                Objects.equals(accountName, emp.accountName) &&
                Objects.equals(empPwd, emp.empPwd) &&
                Objects.equals(empDate, emp.empDate) &&
                Objects.equals(dateEntry, emp.dateEntry);
    }

    @Override
    public int hashCode() {
        return Objects.hash(empName, empSex, empPhone,  empCard, empIsNot, accountName, empPwd, empDate, dateEntry, employeesId);
    }

    @OneToMany(mappedBy = "empByEmployeesId")
    public Collection<Culog> getCulogsByEmployeesId() {
        return culogsByEmployeesId;
    }

    public void setCulogsByEmployeesId(Collection<Culog> culogsByEmployeesId) {
        this.culogsByEmployeesId = culogsByEmployeesId;
    }

    @ManyToOne
    @JoinColumn(name = "depts_id", referencedColumnName = "depts_id")
    public Dept getDeptByDeptsId() {
        return deptByDeptsId;
    }

    public void setDeptByDeptsId(Dept deptByDeptsId) {
        this.deptByDeptsId = deptByDeptsId;
    }



    @OneToMany(mappedBy = "empByEmployeesId")
    public Collection<Evection> getEvectionsByEmployeesId() {
        return evectionsByEmployeesId;
    }

    public void setEvectionsByEmployeesId(Collection<Evection> evectionsByEmployeesId) {
        this.evectionsByEmployeesId = evectionsByEmployeesId;
    }

    @OneToMany(mappedBy = "empByEmployeesId")
    public Collection<Expense> getExpensesByEmployeesId() {
        return expensesByEmployeesId;
    }

    public void setExpensesByEmployeesId(Collection<Expense> expensesByEmployeesId) {
        this.expensesByEmployeesId = expensesByEmployeesId;
    }

    @OneToMany(mappedBy = "empByEmployeesId")
    public Collection<Target> getTargetsByEmployeesId() {
        return targetsByEmployeesId;
    }

    public void setTargetsByEmployeesId(Collection<Target> targetsByEmployeesId) {
        this.targetsByEmployeesId = targetsByEmployeesId;
    }

    @OneToMany(mappedBy = "empByEmployeesId")
    public Collection<Reply> getReplyByEmployeesId() {
        return replyByEmployeesId;
    }

    public void setReplyByEmployeesId(Collection<Reply> replyByEmployeesId) {
        this.replyByEmployeesId = replyByEmployeesId;
    }

    @OneToMany(mappedBy = "empByEmployeesId")
    public Collection<CheckDetails> getCheckDetailsByEmployeesId() {
        return checkDetailsByEmployeesId;
    }

    public void setCheckDetailsByEmployeesId(Collection<CheckDetails> checkDetailsByEmployeesId) {
        this.checkDetailsByEmployeesId = checkDetailsByEmployeesId;
    }

    @Override
    public String toString() {
        return "Emp{" +
                "empName='" + empName + '\'' +
                ", empSex='" + empSex + '\'' +
                ", empPhone='" + empPhone + '\'' +
                ", empCard='" + empCard + '\'' +
                ", empIsNot=" + empIsNot +
                ", accountName='" + accountName + '\'' +
                ", empPwd='" + empPwd + '\'' +
                ", empDate=" + empDate +
                ", dateEntry=" + dateEntry +
                ", employeesId=" + employeesId +
                '}';
    }
}
